home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / amhelios / out_poly.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  2KB  |  89 lines

  1. ////////////////////////////////////////////////////////////
  2. //
  3. /// OUT_POLY.H - Output Polygon Class
  4. //
  5. //  Version:    1.03A
  6. //
  7. //  History:    94/08/23 - Version 1.00A release.
  8. //              94/12/16 - Version 1.01A release.
  9. //              95/02/05 - Version 1.02A release.
  10. //              95/07/21 - Version 1.02B release.
  11. //              96/02/14 - Version 1.02C release.
  12. //              96/04/01 - Version 1.03A release.
  13. //
  14. //  Compilers:  Microsoft Visual C/C++ Professional V1.5
  15. //              Borland C++ Version 4.5
  16. //
  17. //  Author:     Ian Ashdown, P.Eng.
  18. //              byHeart Software Limited
  19. //              620 Ballantree Road
  20. //              West Vancouver, B.C.
  21. //              Canada V7S 1W3
  22. //              Tel. (604) 922-6148
  23. //              Fax. (604) 987-7621
  24. //
  25. //  Copyright 1994-1996 byHeart Software Limited
  26. //
  27. //  The following source code has been derived from:
  28. //
  29. //    Ashdown, I. 1994. Radiosity: A Programmer's
  30. //    Perspective. New York, NY: John Wiley & Sons.
  31. //
  32. //  It may be freely copied, redistributed, and/or modified
  33. //  for personal use ONLY, as long as the copyright notice
  34. //  is included with all source code files.
  35. //
  36. ////////////////////////////////////////////////////////////
  37.  
  38. #ifndef _OUT_POLY_H
  39. #define _OUT_POLY_H
  40.  
  41. #include "vertex4.h"
  42.  
  43. // Maximum  number of output vertices
  44. static const int MaxOutVert = 10;
  45.  
  46. class OutPolygon        // Output polygon
  47. {
  48.   private:
  49.     class OutVertex     // Output vertex
  50.     {
  51.       private:
  52.         Spectra color;  // Color
  53.         Point3 posn;    // 3-D position
  54.  
  55.       public:
  56.         Point3 &GetPosn() { return posn; }
  57.         Spectra &GetColor() { return color; }
  58.  
  59.         void Set( Vertex4 &v )
  60.         {
  61.           // Perform perspective division
  62.           v.GetCoord().Perspective(&posn);
  63.  
  64.           color = v.GetColor();
  65.         }
  66.     }
  67.     vertex[MaxOutVert];     // Output vertex array
  68.     int num_vert;           // Number of vertices
  69.  
  70.     void AddVertex( Vertex4 &v )
  71.     { vertex[num_vert++].Set(v); }
  72.     void Reset() { num_vert = 0; }
  73.  
  74.     friend class ClipEdge;
  75.     friend class PolyClip4;
  76.  
  77.   public:
  78.     OutPolygon() { num_vert = 0; }
  79.  
  80.     int GetNumVert() { return num_vert; }
  81.     Point3 &GetVertexPosn( int i )
  82.     { return vertex[i].GetPosn(); }
  83.     Spectra &GetVertexColor( int i )
  84.     { return vertex[i].GetColor(); }
  85. };
  86.  
  87. #endif
  88.  
  89.